package com.lyt.springboot.util.algorithm;

import java.util.HashMap;
import java.util.Stack;

public class S2 {
    //使用辅助函数
    //其中一个为min栈，从栈底到栈顶，底最大
    Stack<Integer> stack1 = new Stack<>();
    Stack<Integer> stack2 = new Stack<>();

    //push
    public void push(int node) {
        stack1.push(node);
        if (stack2.empty() || node <= stack2.peek()) {
            stack2.push(node);
        }
    }

    //pop
    public void pop() {
        if (!stack1.empty()) {
            if (stack1.peek().intValue() == stack2.peek()) {
                stack2.pop();
            }
            stack1.pop();
        }

    }

    //top
    public int top() {
        return stack1.peek();

    }

    //min
    public int min() {
        return stack2.peek();
    }


    public static void main(String[] args) {
        HashMap<Integer,Integer> hashMap = new HashMap<>(10000);
    }
}
